package com.yantu.controller.student;

import com.yantu.bean.ExamPaper;
import com.yantu.mapper.ExamPaperMapper;
import com.yantu.util.Result;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@ApiModel("学生首页")
@RequestMapping("/student")
public class StudentHomePageController {
    @Autowired
    ExamPaperMapper examPaperMapper;

    @Value("${jwt.tokenHeader}")
    private String tokenHeader;
    //首页
    @GetMapping("/homePage")
    @ApiOperation("学生首页")
    public Result studentHomePage(HttpServletRequest request) {
        String jwtToken = "eyJhbGciOiJIUzUxMiJ9.eyJpZCI6NywidXNlcm5hbWUiOiJzcyJ9.xQyMyoNBHQ6_PaqWhTy-3wxCjjQ6OlTXi0eHOFQQyLFhiuQ-qY_z4YEPgnLdUTigHTyTQH66cYXdqci7Of8MvQ";
        System.out.println("token在这里呀");
        System.out.println(jwtToken);
        List<ExamPaper> examPapers = examPaperMapper.selectList(null);
        List<Object> list1 = new ArrayList();
        for (ExamPaper examPaper : examPapers) {
            Map<String, Object> map = new HashMap<>();
            map.put("id",examPaper.getId());
            map.put("name",examPaper.getName());
            map.put("limitStartTime",examPaper.getLimitStartTime());
            map.put("limitEndTime",examPaper.getLimitEndTime());
            list1.add(map);
        }

            return Result.succ(200, "查询成功", list1);

    }
}
